using Infrastructure.Attribute;
using Infrastructure.Extensions;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Repository;
using JTZY.Service.Order.IOrderService;

namespace JTZY.Service.Order
{
    /// <summary>
    /// 发货单详情表Service业务层处理
    /// </summary>
    [AppService(ServiceType = typeof(ICorecmsbilldeliveryitemService), ServiceLifetime = LifeTime.Transient)]
    public class CorecmsbilldeliveryitemService : BaseService<Corecmsbilldeliveryitem>, ICorecmsbilldeliveryitemService
    {
        /// <summary>
        /// 查询发货单详情表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public PagedInfo<CorecmsbilldeliveryitemDto> GetList(CorecmsbilldeliveryitemQueryDto parm)
        {
            var predicate = QueryExp(parm);

            var response = Queryable()
                .Where(predicate.ToExpression())
                .ToPage<Corecmsbilldeliveryitem, CorecmsbilldeliveryitemDto>(parm);

            return response;
        }


        /// <summary>
        /// 获取详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Corecmsbilldeliveryitem GetInfo(int Id)
        {
            var response = Queryable()
                .Where(x => x.Id == Id)
                .First();

            return response;
        }

        /// <summary>
        /// 添加发货单详情表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Corecmsbilldeliveryitem AddCorecmsbilldeliveryitem(Corecmsbilldeliveryitem model)
        {
            return Insertable(model).ExecuteReturnEntity();
        }

        /// <summary>
        /// 修改发货单详情表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateCorecmsbilldeliveryitem(Corecmsbilldeliveryitem model)
        {
            return Update(model, true);
        }

        /// <summary>
        /// 查询导出表达式
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        private static Expressionable<Corecmsbilldeliveryitem> QueryExp(CorecmsbilldeliveryitemQueryDto parm)
        {
            var predicate = Expressionable.Create<Corecmsbilldeliveryitem>();

            return predicate;
        }
    }
}